using System.Collections.Generic;
using UnityEngine;
namespace DefaultNamespace.Skill
{
    [System.Serializable]
    public class SkillNode
    {
        public Skill skill;
        public List<SkillNode> prerequisites;
        public bool isUnlocked;
    }
    public class SkillTree : MonoBehaviour
    {
        public List<SkillNode> skillNodes;
        public bool UnlockSkill(Skill skill)
        {
            SkillNode node = skillNodes.Find(n => n.skill == skill);
            if (node != null && !node.isUnlocked)
            {
                // Check prerequisites
                bool canUnlock = true;
                foreach (var prereq in node.prerequisites)
                {
                    if (!prereq.isUnlocked)
                    {
                        canUnlock = false;
                        break;
                    }
                }
                if (canUnlock)
                {
                    node.isUnlocked = true;
                    return true;
                }
            }
            return false;
        }
    }
}